package com.cosmoplat.xikai.business.enums;

import com.cosmoplat.xikai.common.utils.StringUtils;
import lombok.Getter;

import java.util.ArrayList;

@Getter
/**
 * 告警
 */
public enum DeviceWarnEnum {


    MECHAICAL_ARM_RELATED_FAULTS("mechanicalArmRelated", "机械臂相关故障"),
    MOTOR_FAILURE1("motor1", "1#马达故障"),
    MOTOR_FAILURE2("motor2", "2#马达故障"),
    MOTOR_FAILURE3("motor3", "3#马达故障"),
    MOTOR_FAILURE4("motor4", "4#马达故障"),
    MOTOR_FAILURE5("motor5", "5#马达故障"),
    MOTOR_FAILURE6("motor6", "6#马达故障"),
    MOTOR_FAILURE7("motor7", "7#马达故障"),
    MOTOR_FAILURE8("motor8", "8#马达故障"),
    MOTOR_FAILURE9("motor9", "9#马达故障"),
    MOTOR_FAILURE10("motor10", "10#马达故障"),
    MOTOR_FAILURE11("motor11", "11#马达故障"),
    MOTOR_FAILURE12("motor12", "12#马达故障"),
    MOTOR_FAILURE13("motor13", "13#马达故障"),
    VISION_SYSTEM_RELATED_FAILURE("visionSystemRelated", "视觉系统相关故障"),
    OTHER_RELATED_FAULTS("otherRelated", "其他相关故障"),
    INSUFFICIENT_OIL_SUPPLY_SYSTEM1("insufficientOilSupplySystem1", "1#供油系统油油量不足"),
    INSUFFICIENT_OIL_SUPPLY_SYSTEM2("insufficientOilSupplySystem2", "2#供油系统油油量不足"),
    INSUFFICIENT_OIL_SUPPLY_SYSTEM3("insufficientOilSupplySystem3", "3#供油系统油油量不足");

    private String identifler;
    private String name;

    DeviceWarnEnum(String identifler, String name) {
        this.identifler = identifler;
        this.name = name;
    }

    public static ArrayList<String> getIdentiflerList() {
        ArrayList<String> list = new ArrayList<>();
        for (DeviceWarnEnum value : values()) {
            list.add(value.getIdentifler());
        }
        return list;
    }

    public static String getIdentiflerByName(String name) {
        if (StringUtils.isBlank(name)) {
            return null;
        }
        for (DeviceWarnEnum value : values()) {
            if (value.getName().equals(name)) {
                return value.getIdentifler();
            }
        }
        return null;
    }

    /**
     * 是否是告警点位
     * @param identifler
     * @return
     */
    public static Boolean isWarningPoint(String identifler) {
        if (StringUtils.isBlank(identifler)) {
            return null;
        }
        for (DeviceWarnEnum value : values()) {
            if (value.getIdentifler().equals(identifler)) {
                return true;
            }
        }
        return false;
    }
}
